<template>
	<view>
		<scroll-view scroll-y="true" style="height:calc(100vh - 600rpx);">
			<view class="all-content" v-for="(item, index) in dataList" :key="index" @click="fnGoDetail(item)">
				<view class="top-content-st top-content">
					<view class="top-ring">{{getContent(item) || ''}}</view>
					<!-- :class="setLevelColor(item.rankClass)" -->
					<view class="top-lv" :class="{'red':item.rankClass === 'tall','orange':item.rankClass === 'central', 'blue':item.rankClass === 'bottom' || item.rankClass === 'nought'}">{{item.diseaseGradeName || ''}}{{item.diseaseNo || ''}}
					</view>
					<view class="top-status">{{setStatus(item.orderState)}}</view>
				</view>
				<view class="top-content">
					<view class="bottem-ev">{{item.diseaseStatus}}</view> 
				</view>
				<view class="top-content">
					<view class="top-time">截止日期:{{getTime(item.repairEndDate)}}</view>
				</view>
				<view class="top-content" style="justify-content: space-between;">
					<view class="top-time">工单号:{{item.repairOrderNo || ''}}</view>
					<view class="top-btn" v-show="item.orderState === 'prepare'" @click.stop="fnRevoke(item.id)">撤销
					</view>
				</view>
			</view>
			<view v-if="dataList.length === 0">
				<u-empty mode="data" text="数据为空" icon="http://cdn.uviewui.com/uview/empty/data.png"></u-empty>
			</view>
		</scroll-view>
		<u-modal :show="showPopup" :content='content' @confirm="popSubmit" @cancel="()=>showPopup = false" :showCancelButton='true'
			:buttonReverse="true" confirmText='是' cancelText='否' cancelColor='red'></u-modal>
	</view>
</template>

<script>
	import mixins from '@/utils/mixins.js'
	import {
		revokeOrder
	} from '@/api/engineeringMaintenance/engineeringMaintenance.js'
	export default {
		name: 'notDispatch',
		mixins: [mixins],
		props: {
			dataList: {
				type: Array,
				default: () => {
					return []
				}
			}
		},
		data() {
			return {
				showPopup: false,
				content:'撤销后该条病害将恢复为未派单状态，确定撤销？'
			}
		},
		methods: {
			setLevelColor(str){
				if(str === 'tall')
				return 'red'
				if(str === 'central')
				return 'orange'
				if(str === 'bottom' || str === 'nought')
				return 'blue'
				return ''
			},
			fnGoDetail(item) {
				console.log('跳转')
				uni.navigateTo({
					url: `/subpackage-enginner/pages/engineeringMaintenance/disease_dispatch/dispatchDetail?id=${item.id}&type=${item.mileage}`
				})
			},
			fnRevoke(id) {
				this.id = id
				this.showPopup = true
			},
			popSubmit() {
				revokeOrder({
					id: this.id
				}).then(res => {
					if (res.success) {
						uni.showToast({
							title: res.message,
							icon: 'none'
						})
						this.$emit('refresh')
					}
				})
				this.showPopup = false

			},
			setStatus(str) {
				if (str === 'prepare') {
					return '未开始'
				} else if (str === 'repairing') {
					return '维修中'
				} else if (str === 'rework') {
					return '需返工'
				} else if (str === 'unaudit') {
					return '待审核'
				} else if (str === 'complete') {
					return '已修复'
				} else {
					return ''
				}
			},
			/**
			 * 高中低无  红橙蓝蓝
			 * **/
			setLevelColor(str) {
				if(str === 'tall') {
					return 'red'
				}else if(str === 'central') {
					return 'orange'
				}else if(str === 'bottom' || str === 'nought') {
					return 'blue'
				}else {
					return ''
				}
			},
			//截止日期
			getTime(str) {
				if(!str) return ''
				return this.getDate(str)
			}
		}
	}
</script>

<style lang="scss" scoped>
	.grey  {background:#d7d7d7 !important;}
	.blue  {background:#0297d7 !important;}
	.orange{background:#f59a23 !important;}
	.green {background:#03b615 !important;}
	.red   {background:#ff6e4a !important;}
	.all-content {
		width: 90%;
		height: 270rpx;
		margin-left: 30rpx;
		margin-top: 30rpx;
		border-bottom: 2rpx dashed #f4f4f5;

		.top-content-st {
			display: flex;
			justify-content: flex-start;
			align-items: center;


		}

		.top-content {
			display: flex;
			justify-content: flex-start;
			align-items: center;
			padding: 6rpx 0;

			.top-ring {
				height: 44rpx;
				font-size: 32rpx;
				font-family: PingFang SC-Bold, PingFang SC;
				font-weight: bold;
				color: #445469;
				line-height: 48rpx;
				margin-right: 20rpx;
				width: auto;
				overflow: hidden;
				white-space: nowrap;
				text-overflow: ellipsis;
			}

			.top-time {
				margin: 10rpx 0;
				height: 40rpx;
				font-size: 32rpx;
				font-family: PingFang SC-Medium, PingFang SC;
				font-weight: 500;
				color: #6A819E;
				line-height: 40rpx;
			}

			.top-btn {
				width: 70rpx;
				color: white;
				text-align: center;
				background-color: #169bd5;
				padding: 0 20rpx;
			}

			.top-lv {
				width: auto;
				padding: 6rpx 20rpx;
				// clip-path: polygon(10rpx 0, 100% 0, calc(100% - 10rpx) 52rpx, 0% 52rpx);
				clip-path: polygon(15rpx 0, 100% 0, calc(100% - 15rpx) 52rpx, 0% 52rpx);
				// border-radius: 13px 4px;
				
				// width: 62rpx;
				height: 40rpx;
				font-size: 28rpx;
				font-family: PingFang SC-Bold, PingFang SC;
				font-weight: bold;
				color: #FFFFFF;
				line-height: 44rpx;
				background: #C6CDD8;
				text-align: center;
			}
			.top-lv.red {
				background: linear-gradient(90deg, #FF2B2B 0%, #FF603D 100%);
				
			}
			.top-lv.orange {
				background: linear-gradient(90deg, #FF882B 0%, #FF9F3D 100%);
			}
			.top-lv.blue {
				background: linear-gradient(90deg, #5295FE 0%, #3FB8FF 100%);
			}
			.top-status {
				min-width: max-content;
				padding: 6rpx 18rpx;
				clip-path: polygon(15rpx 0, 100% 0, calc(100% - 15rpx) 52rpx, 0% 52rpx);
				height: 40rpx;
				font-size: 28rpx;
				font-family: PingFang SC-Bold, PingFang SC;
				font-weight: bold;
				color: #FFFFFF;
				line-height: 44rpx;
				background: #C6CDD8;
				text-align: center;
			}
		}

		.bottem-ev {
			margin: 10rpx 0;
			height: 40rpx;
			font-size: 32rpx;
			font-family: PingFang SC-Medium, PingFang SC;
			font-weight: 500;
			color: #6A819E;
			line-height: 40rpx;
			width: 100%;
			white-space: nowrap;
			text-overflow: ellipsis;
			overflow: hidden;
		}

		.re {
			background: linear-gradient(90deg, #FF882B 0%, #FF9F3D 100%) !important;
		}

	}
</style>
